//
//  GlobalState.m
//  healthApp
//
//  Created by william mu on 12-8-28.
//  Copyright (c) 2012年 Tencent. All rights reserved.
//

#import "GlobalState.h"
#import "ProtocolService.h"
#import "WaitUtility.h"
#import "ProtocolTranslate.h"

static id s_instance = nil;
static bool proceed = false;

@implementation GlobalState
@synthesize uid;
@synthesize healthFieldMap;
@synthesize symptomMap;

-(id) init
{
    if(self = [super init])
    {
        m_uid = nil;
        m_protocol = [ProtocolService sharedInstance];

        m_symptomCode2name = nil;
    }
    
    return self;
}

+(GlobalState*) sharedInstance
{
    if(!s_instance)
        s_instance = [[GlobalState alloc] init];
    
    return s_instance;
}

-(NSString*) mapSymptomCode2Name:(NSString*) code
{
    return [self.symptomMap objectForKey:code];
}

-(NSString*) mapSymptomName2Code:(NSString*) name
{
    for(NSString* symptomCode in self.symptomMap)
    {
        NSString* symptomName = [self.symptomMap objectForKey:symptomCode];
        NSRange range = [symptomName rangeOfString:name];
        if(range.location != NSNotFound)
            return symptomCode;
    }
    
    return @"";
}


@end
